package org.daochong.lang;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public abstract class BeanTransfer<M, N> {
	private Class<M> source;
	private Class<N> target;

	@SuppressWarnings("unchecked")
	public BeanTransfer() {
		Type[] types = ((ParameterizedType) getClass().getGenericSuperclass())
				.getActualTypeArguments();
		this.source = (Class<M>) types[0];
		this.target = (Class<N>) types[1];
		BeanUtil.transfers.put(source.toString() + "_" + target.toString(),
				this);
	}

	public Class<?> getSource() {
		return source;
	}

	public Class<?> getTarget() {
		return target;
	}

	public abstract N transfer(M val);

}
